package top.jwtTokenPlugin.Bean;

import top.jwtTokenPlugin.Bean.IJwtAble;

import java.util.Date;
import java.util.List;

/**
 * 我有故事，你有酒么？
 * JKhaled created by yunqisong@foxmail.com 2017/7/29
 * FOR : JwtBean
 */
public class JwtBean implements IJwtAble {

    private String userName;                                // 参与构建token的字段--存入到map中的key

    private String password;                                // 服务器储存

    private List<String> roles;                             //  服务器校验通过后存储的角色

    private List<String> forces;                            //  服务器校验通过后存储的权限

    private Date lastModifyPasswordTime;                  //  上次修改密码时间

    public static JwtBean created(IJwtAble user) {
        return new JwtBean().setForces(user.getForces())
                .setLastModifyPasswordTime(user.getLastModifyPasswordTime())
                .setRoles(user.getRoles());
    }

    public String getUserName() {
        return userName;
    }

    public JwtBean setUserName(String userName) {
        this.userName = userName;
        return this;
    }

    public String getPassword() {
        return password;
    }

    public JwtBean setPassword(String password) {
        this.password = password;
        return this;
    }

    public List<String> getRoles() {
        return roles;
    }

    public JwtBean setRoles(List<String> roles) {
        this.roles = roles;
        return this;
    }

    public List<String> getForces() {
        return forces;
    }

    public JwtBean setForces(List<String> forces) {
        this.forces = forces;
        return this;
    }

    public Date getLastModifyPasswordTime() {
        return lastModifyPasswordTime;
    }

    public JwtBean setLastModifyPasswordTime(Date lastModifyPasswordTime) {
        this.lastModifyPasswordTime = lastModifyPasswordTime;
        return this;
    }

    @Override
    public String toString() {
        return "JwtBean{" +
                "userName='" + userName + '\'' +
                ", password='" + password + '\'' +
                ", roles=" + roles +
                ", forces=" + forces +
                ", lastModifyPasswordTime=" + lastModifyPasswordTime +
                '}';
    }
}
